import { FilterConst } from "../../../component/gconst/FilterConst";
import { GBox } from "../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../com/mui/containers/globalVariable/GBoxDirection";
import { LoginNoticeInfo } from "../../model/LoginNoticeInfo";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ObjectPool } from "../../../../com/gengine/utils/pools/ObjectPool";
import { DegreeRewardIndexItem } from "../daily/reward/DegreeRewardIndexItem";
type int = number;
//class LoginNoticeItem
    
    export  class LoginNoticeItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            this._noticeTxt = new Object /* flash.text.TextField */();
            this._noticeTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._noticeTxt.width = 500;
            this._noticeTxt.height = 18;
            this._noticeTxt.x = 0;
            this._noticeTxt.y = 0;
            this._noticeTxt.mouseEnabled = false;
            this._noticeTxt.filters = [FilterConst.nameGlowFilter];
            addChild(this._noticeTxt);
            this._itemBox = new GBox();
            this._itemBox.y = 0;
            this._itemBox.direction = GBoxDirection.HORIZONTAL;
            this._itemBox.horizontalGap = 2;
            return;
        }

        public updateData(arg1: LoginNoticeInfo): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=null;
            var loc4=null;
            this._info = arg1;
            this._noticeTxt.htmlText = HTMLUtil.addColor(arg1.notice, GlobalStyle.color1);
            if (this.type != 0) 
            {
                this._noticeTxt.y = 0;
            }
            else 
            {
                this._noticeTxt.y = (37 - this._noticeTxt.textHeight) / 2;
            }
            this._noticeTxt.y = (37 - this._noticeTxt.textHeight) / 2;
            if (arg1.items.length > 0) 
            {
                loc2 = arg1.items.length;
                while (loc1 < loc2) 
                {
                    loc3 = arg1.items[loc1];
                    (loc4 = ObjectPool.getObject(DegreeRewardIndexItem)).updateData(loc3, 1);
                    this._itemBox.addChild(loc4);
                    ++loc1;
                }
                this._itemBox.invalidate();
                if (!contains(this._itemBox)) 
                {
                    addChild(this._itemBox);
                }
                this._noticeTxt.y = (37 - this._noticeTxt.textHeight) / 2;
            }
            return;
        }

        public get type(): int
        {
            return this._info.type;
        }

        public updateBoxPos(arg1: int): void
        {
            if (this._itemBox && contains(this._itemBox)) 
            {
                this._itemBox.x = arg1 + 10;
            }
            return;
        }

        public hasItemBox(): Boolean
        {
            return this._itemBox && this._itemBox.numChildren > 0;
        }

        public get textWidth(): int
        {
            return this._noticeTxt.textWidth;
        }

        public dispose(): void
        {
            var loc1=null;
            this._info = null;
            while (this._itemBox.numChildren > 0) 
            {
                loc1 = this._itemBox.removeChildAt(0) as DegreeRewardIndexItem;
                ObjectPool.disposeObject(loc1, DegreeRewardIndexItem);
                loc1.dispose();
            }
            return;
        }

        public /* override */ get width(): number
        {
            var loc1=this._noticeTxt.textWidth;
            if (this._itemBox && this._itemBox.numChildren > 0) 
            {
                loc1 = loc1 + this._itemBox.numChildren * 37;
            }
            return loc1;
        }

        public /* override */ get height(): number
        {
            if (this.type == 0 || this._itemBox && this._itemBox.numChildren > 0) 
            {
                return 37;
            }
            return 20;
        }

        /* internal */ /* var */_noticeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_itemBox: GBox;

        /* internal */ /* var */_info: LoginNoticeInfo;
    }
